﻿using System.Text;
using System.Xml;
using System.Web.Mvc;
using System.Xml.Linq;

namespace WeBlog.ActionResults {
	public class XmlActionResult : ActionResult {
        public XDocument Xml { get; set; }

		public override void ExecuteResult(ControllerContext context ) {            
            context.HttpContext.Response.ContentType = "text/xml";
            context.HttpContext.Response.HeaderEncoding = Encoding.UTF8;

            using (XmlWriter writer = XmlWriter.Create(context.HttpContext.Response.Output))
            {
                Xml.WriteTo(writer);
            }
        }
	}
}